﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;


public partial class Semester_AllSemesterInfo : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

        string connStr = ConfigurationManager.ConnectionStrings["ConnStr"].ToString();
        SqlConnection conn = new SqlConnection(connStr);
        SqlDataAdapter dAd = new SqlDataAdapter();
        SqlCommand dCmd = new SqlCommand();
        DataTable dTable = new DataTable();
        try
        {
            dCmd.CommandText = "SelectAllSemester";
            dCmd.CommandType = CommandType.StoredProcedure;
            dCmd.Connection = conn;
            //SqlParameter prm = new SqlParameter("@firstName", SqlDbType.VarChar, 50);
            //prm.Value = keyword;
            // add the parameters into command
            //dCmd.Parameters.Add(prm);
            // assign the select command to the Adapter object
            dAd.SelectCommand = dCmd;
            // now open the connection
            conn.Open();
            dAd.Fill(dTable);
            conn.Close(); // close the connection
            
        }

        catch (Exception ee)
        {
            string ex = ee.ToString();
            //lblMessage.Text = ee.Message.ToString()
        }

        finally
        {
            dCmd.Clone();
            dAd.Dispose();
            conn.Dispose();
        }

        // Bind the record now
        SemesterInfoGridView.DataSource = dTable;
        //GridView1.AutoGenerateEditButton = true;
        //GridView1.AutoGenerateDeleteButton = true;
        //GridView1.EditIndex = 3;
        //GridView1.

        SemesterInfoGridView.DataBind();
    }
}